package com.yidu.BusinessData.controller;



import com.yidu.BusinessData.entity.SecurityEntity;
import com.yidu.BusinessData.service.SecurityService;
import com.yidu.Util.util.Dbutil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**@description: 证券信息控制器
 *@author: 肖理
 *@create: 2022-09-10
 **/
@RestController
public class SecurityController {
    @Autowired
    SecurityService securityService;
    @Autowired
    Dbutil dbutil;
    //证券信息查询
    @RequestMapping("/select")
    public Map selectSecurity(String securityName,int page,int limit){
        Map map = new HashMap();
        System.out.println(securityName);
        //securityName==null?"":securityName
        if(securityName==null){
            securityName="";
        }
        List<SecurityEntity> securityEntityList= securityService.securitySelect(securityName,page,limit);
        System.out.println(securityEntityList+"整卷");
        map.put("code","0");
        map.put("msg","成功");
        map.put("count",securityService.securitySelecttwo(securityName));
        map.put("data",securityEntityList);
        return map;
    }
    //证券信息增加
    @RequestMapping("/insertSecurity")
    public String insertSecurity(SecurityEntity securityEntity){
        int i = securityService.securityInsert(securityEntity);
        if (i>0) {
            return "ok";
        }else {
            return "no";
        }
    }
    //证券信息删除
    @RequestMapping("/delete")
    public String deleteSecurity(String securityId){
        System.out.println(securityId);
        int i = securityService.securityDelete(securityId);
        System.out.println(i);
        if (i>0) {
            return "ok";
        }else {
            return "no";
        }
    }
    //证券信息修改
    @RequestMapping("/update")
    public String updateSecurity(SecurityEntity securityEntity){
        int i = securityService.securityUpdate(securityEntity);
        System.out.println(securityEntity.getSecuritType());
        System.out.println(i);
        if (i>0) {
            return "ok";
        }else {
            return "no";
        }
    }
}
